/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package failuremodule;

import comunicacao.ReceiveMessageInterface;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 *
  * @author Leonardo Lino Nº45340
 * @author Diogo Pires Nº40351
 */
public class FailureModule {

    /**
     * Usage: java FailureModule {address} {port} {fail/restart}
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       JanelaPrincipal jp = new JanelaPrincipal();
       jp.setVisible(true);
    }
    
    
    private void old(){
        /*
         ReceiveMessageInterface rmiServer;
        Registry registry;
        String serverAddress = args[0];
        String serverPort = args[1];
        String mode = args[2];

        if (mode.equals("fail")) {
            System.out.println("sending failure signal to " + serverAddress + ":" + serverPort);
            try {

                // get the �gregistry�h
                registry = LocateRegistry.getRegistry(
                        serverAddress,
                        (new Integer(serverPort)).intValue()
                );
                // look up the remote object
                rmiServer
                        = (ReceiveMessageInterface) (registry.lookup("dbServer"));
                // call the remote method
                rmiServer.falha();
            } catch (RemoteException e) {
                e.printStackTrace();
            } catch (NotBoundException e) {
                e.printStackTrace();
            }
        } else if (mode.equals("restart")) {
            System.out.println("sending restart signal to " + serverAddress + ":" + serverPort);
            try {

                // get the �gregistry�h
                registry = LocateRegistry.getRegistry(
                        serverAddress,
                        (new Integer(serverPort)).intValue()
                );
                // look up the remote object
                rmiServer
                        = (ReceiveMessageInterface) (registry.lookup("dbServertemp"));
                // call the remote method
                rmiServer.restart();
            } catch (RemoteException e) {
                e.printStackTrace();
            } catch (NotBoundException e) {
                e.printStackTrace();
            }
        }
                */
    }

}
